from django.db import models
from user.models import SysUser
import uuid
class VideoHistory(models.Model):
    user = models.ForeignKey(SysUser, on_delete=models.CASCADE, related_name='video_histories', verbose_name="用户", db_comment="关联用户")
    task_id = models.CharField(max_length=100, unique=True, null=True, blank=True, verbose_name="任务ID", db_comment="Celery任务ID")
    prompt = models.TextField(verbose_name="提示词", db_comment="用户输入的提示词")
    mode = models.CharField(max_length=20, choices=[('text', '文生视频'), ('image', '图生视频'), ('frames', '首尾帧生视频')], verbose_name="生成模式", db_comment="视频生成模式")
    image_url = models.TextField(null=True, blank=True, verbose_name="输入图片", db_comment="图生视频或首尾帧的图片数据")
    video_url = models.URLField(verbose_name="视频URL", db_comment="生成的视频URL")
    status = models.CharField(max_length=20, default='SUCCESS', choices=[('SUCCESS', '成功'), ('FAILURE', '失败'), ('PENDING', '处理中')], verbose_name="状态", db_comment="任务状态")
    quality = models.CharField(max_length=20, choices=[('speed', '快速'), ('quality', '高质量')], default='quality', null=True, blank=True, verbose_name="质量", db_comment="视频生成质量")
    fps = models.IntegerField(default=30, null=True, blank=True, verbose_name="帧率", db_comment="视频帧率")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间", db_comment="生成时间")
    updated_at = models.DateTimeField(auto_now=True, verbose_name="更新时间", db_comment="更新时间")
    local_video_path = models.FileField(upload_to='videos/', null=True, blank=True, verbose_name="本地视频路径",db_comment="本地存储的视频文件")

    class Meta:
        db_table = "video_history"
        verbose_name = "视频生成历史"
        ordering = ['-created_at']

    def __str__(self):
        return f"{self.user.username} 的视频生成记录 - {self.created_at}"


from django.db import models

# Create your models here.
